package wechat

import (
	"wxsdk/oauth"
	"github.com/astaxie/beego"
)

// 代管登陆并下载用户信息
func PubBuyerLogin(appId, isvAppId, isvAccessToken, code string) (openId string,sessionKey string,err error) {
	openId, sessionKey, err = oauth.AssistPubCode2Session(appId, isvAppId, isvAccessToken, code)
	if err != nil {
	    beego.Debug(err.Error())
		return
	}
	return
}

func PubGetBuyerUserInfo(openId, sessionKey string) (userInfo oauth.BuyerUserInfo, err error) {
	userInfo, err = oauth.GetUserInfo(sessionKey, openId)
	if err != nil {
	    beego.Debug(err.Error())
		return
	}
	beego.Debug("AppletBuyerLogin:", userInfo)
	userInfo.SessionKey = sessionKey
	return
}
